External Exam Download Resources Web Applications Games Recycle Bin

Flask templates

fullscreen view source
  • server.py
    • static folder
      • css & js files
      • all other static files
    • templates folder
      • template.html
      • all dynamic html files
Put template.html in a templates folder:

templates\template.html

<h1>This is a html template.</h1>

server.py

from flask import *
app = Flask("template rendering")

@app.route("/")
def main():
    return render_template("template.html")
 
app.run(debug=True)


By default, name your HTML templates folder exactly templates. It matters.


To request the rendered template navigate to http://127.0.0.1:5000/